<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tChannel-add">

			<div class="form-group">	
				<label class="col-sm-3 control-label">名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Appid：</label>
				<div class="col-sm-8">
					<input id="appId" name="appId" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">缩略图：</label>
				<div class="col-sm-8">
					<input id="iconPath" name="iconPath" class="form-control" type="hidden"/>
					<img width="155px" height="120px" id="img1" />
					<button type="button" class="layui-btn" id="file1">
						<i class="fa fa-cloud"></i>上传图片
					</button>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">二维码图：</label>
				<div class="col-sm-8">
					<input id="qrcodePath" name="qrcodePath" class="form-control" type="hidden">
					<img width="155px" height="120px" id="img2" />
					<button type="button" class="layui-btn" id="file2">
						<i class="fa fa-cloud"></i>上传图片
					</button>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">对方路径：</label>
				<div class="col-sm-8">
					<input id="pagePath" name="pagePath" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">我方路径：</label>
				<div class="col-sm-8">
					<input id="mePagePath" name="mePagePath" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">描述：</label>
				<div class="col-sm-8">
					<input id="descr" name="descr" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="status" name="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">帐号状态（0正常 1停用）：</label>
				<div class="col-sm-8">
					<input id="status" name="status" class="form-control" type="text">
				</div>
			</div>-->
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "treasure/tChannel"
		$("#form-tChannel-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            //$.operate.save(prefix + "/add", $('#form-tChannel-add').serialize());
                add();
	        }
	    }

        function add() {
            var name = $("input[name='name']").val();
            var appId = $("input[name='appId']").val();
            var iconPath = $("input[name='iconPath']").val();
            var qrcodePath = $("input[name='qrcodePath']").val();
            var pagePath = $("input[name='pagePath']").val();
            var mePagePath = $("input[name='mePagePath']").val();
            var descr = $("input[name='descr']").val();
            var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/add",
                data : {
                    "name": name,
					"appId":appId,
                    "iconPath":iconPath,
                    "qrcodePath":qrcodePath,
                    "pagePath":pagePath,
					"mePagePath":mePagePath,
                    "descr":descr,
                    "status": status
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
            });
        }
	</script>
	<script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script>
	<script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script>
	<script>

        layui.use('upload', function() {
            alert("upload");
            var upload = layui.upload;
            //执行实例
            var uploadInst = upload.render({
                elem : '#file1', //绑定元素
                url : ctx + 'common/sysFile/upload1', //上传接口
                size : 1000,
                accept : 'file',
                done : function(r) {
                    alert(r.url);
                    var fileName = r.url;
                    $("#iconPath").val(fileName);
                    $("#img1").attr("src",fileName);
                },
                error : function(r) {
                    layer.msg(r.msg);
                }
            });
            var uploadInst = upload.render({
                elem : '#file2', //绑定元素
                url : ctx + 'common/sysFile/upload1', //上传接口
                size : 1000,
                accept : 'file',
                done : function(r) {
                    var fileName = r.url;
                    $("#qrcodePath").val(fileName);
                    $("#img2").attr("src",fileName);
                },
                error : function(r) {
                    layer.msg(r.msg);
                }
            });
        });
	</script>
</body>
</html>
